package com.ruoyi.business;

import Ice.Communicator;
import Ice.InitializationData;
import com.ruoyi.business.PortServerIce.TradeServantPrx;
import com.ruoyi.business.dto.PSIceOrderCancel;
import com.ruoyi.business.enumType.PSIceMarket;
import com.ruoyi.business.enumType.PSIceOrderType;
import com.ruoyi.business.helper.TradeServantPrxHelper;
import com.ruoyi.business.holder.PSIceErrorCodeHolder;
import com.ruoyi.business.holder.PSIceOrderCancelOutHolder;


/**
 * @Program:iceTest
 * @description:
 * @author: ronghaohua
 * @create: 2024-04-12 14:54:51
 **/
public class OrderCancelClient {
    public static void main(String[] args) {
        InitializationData initData = new InitializationData();
        Communicator communicator = Ice.Util.initialize(initData);

        try {
            //本机调用 TradeServantService:default -p 9000
            TradeServantPrx tradeServantPrx = TradeServantPrxHelper.checkedCast(communicator.stringToProxy("TradeService:tcp -h 192.168.0.101  -p 60010"));


            if (tradeServantPrx == null) {
                System.err.println("Invalid proxy");
                System.exit(1);
            }
            PSIceOrderCancel psIceOrderCancel = new PSIceOrderCancel(PSIceOrderType.Buy, null, 0, "F2-e5f623da-974d-4aad-9c0f-defad951813d", PSIceMarket.SH, "512000", 1000, null);
            PSIceOrderCancelOutHolder psIceOrderCancelOutHolder = new PSIceOrderCancelOutHolder();
            PSIceErrorCodeHolder psIceErrorCodeHolder = new PSIceErrorCodeHolder();
            int i = tradeServantPrx.CancelOrder(null, psIceOrderCancel, psIceOrderCancelOutHolder, psIceErrorCodeHolder);
            System.out.println("Received result from server: " + i);
        } finally {
            communicator.destroy();
        }
    }
}
